#define _CRT_SECURE_NO_WARNINGS 1

#include <vector>
#include <string>
using namespace std;

class Solution {
public:
    vector<int> diStringMatch(string s) {
        int min = 0;
        int max = s.size();
        vector<int> ret;
        for (auto ch : s)
        {
            if (ch == 'I')
                ret.push_back(min++);
            else
                ret.push_back(max--);
        }
        ret.push_back(max);
        return ret;
    }
};